﻿using Artech.Common;
using Artech.Core.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace Artech.Core.Resources.Configuration
{
    public class WcfResourceProviderData: ResourceProviderDataBase, IWcfProviderData
    {
        public WcfResourceProviderData() { }
        public WcfResourceProviderData(Type type)
            : base(null, type) { }
        public WcfResourceProviderData(string name, Type type)
            : base(name, type) { }

        [ConfigurationProperty(Constants.ConfigurationProperties.Endpoint, IsRequired = true)]
        public string EndpointName
        {
            get { return (string)base[Constants.ConfigurationProperties.Endpoint]; }
            set { base[Constants.ConfigurationProperties.Endpoint] = value; }
        }

        protected override Expression<Func<IResourceProvider>> CreateProvider(IConfigurationSource configurationSource)
        {
            return () => new WcfResourceProvider(this.EndpointName, this.CacheEnabled, this.CacheGranularity, this.CacheStoreAccessor);
        }
    }
}
